import turtle as t
import math as m

a=25
w=30
h=20
five_stars=[(5,5),(10,2),(12,4),(12,7),(10,9)]

def move_to(x,y):
    t.pu()
    t.goto(x,y)
    t.pd()
def draw_rectangle(c):
    t.color(c)
    move_to(-w/2*a,h/2*a)
    t.begin_fill()
    for i in range(2):
        t.fd(w*a)
        t.right(90)
        t.fd(h*a)
        t.right(90)
    t.end_fill()

def draw_grid(c):
    t.color(c)
    for i in range(h//2+1):
        move_to(-w/2*a,h/2*a-i*a)
        t.fd(w/2*a)

    t.seth(-90)
    for i in range(w//2+1):
        move_to(-w/2*a+i*a,h/2*a)
        t.fd(h/2*a)

def draw_line(x1,y1,x2,y2,c):
    t.color(c)
    t.penup()
    t.goto(x1*a,y1*a)
    t.pendown()
    t.goto(x2*a,y2*a)

def draw_ligature(c):
    for i in range(1,5):
        draw_line(five_stars[0][0]-w/2,h/2-five_stars[0][1],five_stars[i][0]-w/2,h/2-five_stars[i][1],c)

def draw_fivestar(r,c):
    t.color(c)
    t.right(90+72)
    t.begin_fill()
    for i in range(5):
        t.fd(2*r*a*m.cos(18*m.pi/180))
        t.right(144)
    t.end_fill()

def set_point(x,y,r):
    move_to(-w/2*a+x*a,h/2*a-y*a)
    if five_stars[0][0]!=x:
        if y<five_stars[0][1]:
            t.seth(-90 - m.atan(m.fabs((x-five_stars[0][0]/y-five_stars[0][1])))*180/m.pi)
        else:
            t.seth(90+m.atan(m.fabs((x-five_stars[0][0]/y-five_stars[0][1])))*180/m.pi)
    else:
        t.seth(90)
    t.pu()
    t.fd(r*a)
    t.pd()

def write_sth(x,y,sth,c='red',ps=16):
    move_to(x*a,y*a)
    t.color(c)
    t.pensize(ps)
    t.write('{0:^3}'.format(sth),font=('黑体',ps,'normal'))

t.speed(9)
t.setup(w*a+100,h*a+100)
draw_rectangle('red')

for i in range(5):
    size = (3 if i == 0 else 1)
    set_point(five_stars[i][0],five_stars[i][1],size)
    draw_fivestar(size,'yellow')

write_sth(-w/8,-h/2-40/a,'我爱你,中国',ps=24)

t.ht()
t.done()